#include "applyfriendrequestmessagetoclient.h"


ApplyFriendRequestMessageToClient::ApplyFriendRequestMessageToClient(const UserId& receiverId,
                        const FriendId& applicantId, const Nickname& nickname,
                        const VerifyInfo& verifyInfo, const CreateTime& applyTime, const Id& id)
{
    m_messageType = MessageType::ApplyFriendRequestToClient;
    m_receiverId = receiverId;
    m_applicantId = applicantId;
    m_nickname = nickname;
    m_verifyInfo = verifyInfo;
    m_applyTime = applyTime;
    m_id = id;
}

ApplyFriendRequestMessageToClient::ApplyFriendRequestMessageToClient(const QJsonObject& jsonObj)
{
    m_messageType = static_cast<MessageType>(jsonObj[JsonKey::TYPE].toInt());
    m_receiverId = jsonObj[JsonKey::USER_ID].toString();
    m_applicantId = jsonObj[JsonKey::FRIEND_ID].toString();
    m_nickname = jsonObj[JsonKey::NICKNAME].toString();
    m_verifyInfo = jsonObj[JsonKey::VERIFY_INFO].toString();
    m_applyTime = jsonObj[JsonKey::CREATE_TIME].toString();
    m_id = jsonObj[JsonKey::ID].toInt();
}

QJsonObject ApplyFriendRequestMessageToClient::PackJsonData() const
{
    QJsonObject jsonObj;
    jsonObj[JsonKey::TYPE] = static_cast<int>(m_messageType);
    jsonObj[JsonKey::USER_ID] = m_receiverId;
    jsonObj[JsonKey::FRIEND_ID] = m_applicantId;
    jsonObj[JsonKey::NICKNAME] = m_nickname;
    jsonObj[JsonKey::VERIFY_INFO] = m_verifyInfo;
    jsonObj[JsonKey::CREATE_TIME] = m_applyTime;
    jsonObj[JsonKey::ID] = m_id;
    return jsonObj;
}

UserId ApplyFriendRequestMessageToClient::getReceiverId() const
{
    return m_receiverId;
}

FriendId ApplyFriendRequestMessageToClient::getApplicantId() const
{
    return m_applicantId;
}

Nickname ApplyFriendRequestMessageToClient::getNickname() const
{
    return m_nickname;
}

VerifyInfo ApplyFriendRequestMessageToClient::getVerifyInfo() const
{
    return m_verifyInfo;
}

CreateTime ApplyFriendRequestMessageToClient::getApplyTime() const
{
    return m_applyTime;
}

int ApplyFriendRequestMessageToClient::getId() const
{
    return m_id;
}
